package com.riant.day03.demo03;


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * @Classname TestFile4
 * @Description TODO
 * @Date 2021/3/5 23:57
 * @Created by 张斌
 */
public class TestFile4 {
    public static void main(String[] args) {
        testFileBuf();
    }
    public static void testFileBuf(){
        File file=new File("day01\\src\\main\\java\\com\\riant\\day03\\demo03\\a.txt");
        byte[] bytes = new byte[1024];
        try {
            InputStream in = new FileInputStream(file);
            BufferedInputStream bufferedInputStream=new BufferedInputStream(in);
            int len=0;
            StringBuffer stringBuffer=new StringBuffer();
            while((len=bufferedInputStream.read(bytes))!=-1){
               stringBuffer.append(new String(bytes,0,len));
            }
            bufferedInputStream.close();
            System.out.println(stringBuffer);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
